/*
Copyright (C) 2015 Pieter Staal

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef BIOMEGENERATOR_H
#define BIOMEGENERATOR_H
#include <SFML/Graphics.hpp>

using namespace sf;

enum Biome {
    OCEAN,
    RIVER,
    LAKE,
    PLAINS,
    DECIDUOUS_FOREST,
    CONIFEROUS_FOREST,
    DESERT,
    ROCK,
    BEACH,
    SNOW
};

const Color biomeColors[]
{
    Color(0, 0, 150), // OCEAN
    Color(0, 32, 150), // RIVER
    Color(29, 89, 140), // LAKE
    Color(4, 179, 47), // PLAINS
    Color(24, 115, 1), // DECIDUOUS FOREST
    Color(8, 64, 24), // CONIFEROUS FOREST
    Color(225, 232, 146), // DESERT
    Color(150, 150, 150), // ROCK
    Color(237, 237, 119), // BEACH
    Color(255, 255, 255)
};

struct BiomeSettings
{
    int size; //of the heightmap
    double *heightmap;
    bool   *landmap;
    double *watermap;
    double *groundWatermap;
    double *heatmap;
    double *windmap;
    double waterLevel;
};

class BiomeGenerator
{
    public:
        BiomeGenerator(BiomeSettings settings);
        void generateBiomes();
        Biome *getBiomeMap();
        Image getImage();
        Image getRawImage();
    protected:
    private:
        Biome getBiomeForPosition(int x, int y);

        Biome *biomemap;
        double scale = 5000; //This means the highest point of the map is 5000 meters high.
        double waterLevel = 0;

        double *heightmap;
        bool   *landmap;
        double *watermap;
        double *groundWatermap;
        double *heatmap;
        double *windmap;

        BiomeSettings settings;
};

#endif // BIOMEGENERATOR_H
